/*============================================================================*/
/*                        Tortoise Team			                              */
/*============================================================================*/
/*                        OBJECT SPECIFICATION                                */
/*============================================================================*
* C Include:        %HAL_Linear_Camera.h%
* Instance:         RPL_1
* %version:         1.1 %
* %created_by:      Andres Torres Garcia %
* %date_created:    Satur Sep 15 09:13:01 2012 %
*=============================================================================*/
/* DESCRIPTION : Declare the functions of the hardware abstraction layer of   */
/*				 the Linear Camera                                            */
/*============================================================================*/
/* FUNCTION COMMENT : Header file of the hardware abstraction layer of the    */
/*					  Linear Camera    								          */
/*                                                                            */
/*============================================================================*/
/*                               OBJECT HISTORY                               */
/*============================================================================*/
/*  REVISION |   DATE      |                               |      AUTHOR      */
/*----------------------------------------------------------------------------*/
/*  1.0      | 15/09/2012  | SAR/SIF/SCN_xxx               | Andres Torres    */
/*  1.1      | 11/10/2012  | SAR/SIF/SCN_xxx               | Andres Torres    */
/*  1.2      | 13/11/2012  | SAR/SIF/SCN_xxx               | Andres Torres    */
/* Integration under Continuus CM                                             */
/*============================================================================*/

#ifndef HAL_LINEAR_CAMERA_H                               /* To avoid double inclusion */
#define HAL_LINEAR_CAMERA_H

/* Includes */
/* -------- */
#include "MAL_PWM.h"
#include "MAL_IOAPI.h"

/* Exported types and constants */
/* ---------------------------- */

/*!
  \def NOISE_FILTER_PRESENT
  Define to know is the noise filter is present.
*/
#define NOISE_FILTER_PRESENT
//#define FREESCALE_CAMERA

/*!
  \def NUM_PIXELS
  Number of pixels of the linear camera.
*/
#ifdef NOISE_FILTER_PRESENT

	#define NUM_PIXELS	127
	
#elif defined (FREESCALE_CAMERA)

	#define NUM_PIXELS	124

#else

	#define NUM_PIXELS	128
	
#endif

#if defined(NOISE_FILTER_PRESENT) || defined(FREESCALE_CAMERA)

	#define RETARD

#endif

/* Types definition */
/* typedef */

/*==================================================*/ 
/* Declaration of exported constants                */
/*==================================================*/


 
/* BYTE constants */

/* WORD constants */

/* LONG and STRUCTURE constants */


/*======================================================*/ 
/* Definition of RAM variables                          */
/*======================================================*/ 
/* BYTES */

/* WORDS */

extern T_SWORD sw_Pixels[NUM_PIXELS];

/* LONGS and STRUCTURES */

/*======================================================*/ 
/* close variable declaration sections                  */
/*======================================================*/ 

/* Exported functions prototypes and macros */
/* ---------------------------------------- */

/* Functions prototypes */

extern void vfnInitCamera(void);
extern void vfnStopCamera(void);
extern void vfnStartCamera(void);
extern void vfnStartCapturing(void);
extern void vfnStopCapturing(void);
extern void vfnCapturePixels(void);
extern void vfnInterrupToCapturePix(void);

/* Functions macros */

/* Exported defines */

/**
 * \defgroup eMIOS channels and pins used by the camera.
 * @{
 */
#define	CHANNEL_CK			5
#define CHANNEL_CNT_CK		23
#define PIN_CK				pin_PB13


#define CHANNEL_SI    		3
#define CHANNEL_CNT_SI		0
#define PIN_SI				pin_PB11

#define CHANNEL_TRIG   		11
#define CHANNEL_CNT_TRIG	8
#define PIN_TRIG			pin_PA11

#define CHANNEL_TRIG_ADC   		2
#define CHANNEL_CNT_TRIG_ADC	23
#define PIN_TRIG_ADC			pin_PA2

#define CLK_PERIOD	40
#define SI_PERIOD	20000

/**@}*/

#endif